/*个人触发器*//*执行函数*/
CREATE OR REPLACE FUNCTION delete_family()
returns trigger as $$

begin
	delete from event where family_id = old.family_id;
	return old;
end;
$$
language plpgsql;

CREATE TRIGGER delete_family_trigger
after delete on family
for each row execute procedure delete_family();



CREATE OR REPLACE FUNCTION delete_people()
returns trigger as $$

begin
	delete from family where people_id = old.people_id;
	return old;
end;
$$
language plpgsql;

CREATE TRIGGER delete_people_trigger
after delete on people
for each row execute procedure delete_people();
/*更新*/
create or replace function update_people()
	returns trigger as $$
	begin 
		update family set people_id = new.people_id;
		return new;
	end;
	$$
	language plpgsql;
	
	create trigger update_people_trigger
	after update of "people_id" on people
	for each row execute procedure update_people();